package com.vue.vue.service.impl;

import com.vue.vue.pojo.Chart;
import com.vue.vue.service.IChartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.Arrays;
import java.util.List;

@Service
public class ChartServiceImpl implements IChartService {


    @Autowired
    private RestTemplate restTemplate;

    /**
     * 查询图表数据测试
     * @param username
     * @return
     */
    @Override
    public List<Chart> chartList(String username) {

        Chart[] forObject = restTemplate.getForObject("http://chart-service/api/v1/chart/list?username="+username, Chart[].class);

        List<Chart> chartList = Arrays.asList(forObject);

        System.out.println(forObject);

        return chartList;
    }
}
